<?php

namespace Home\Model;

use Think\Model;

class DymanicModel extends Model
{
    protected $insertFields = array('datetime', 'citys', 'fabu_city', 'sumbImage', 'masterimg', 'content', 'userid', 'lover', 'thumbsup', 'call', 'filter');

    public function _before_insert(&$data, $options)
    {
        $masterimg = I('masterimg');

        if ($masterimg) {
            $masterimg = explode(',', $masterimg);

            $sumbImage = '';
            foreach ($masterimg as $k => $v) {
                $thumb_ = explode('.', $v);

                $thumb1 = $thumb_[0] . '_thumb.' . $thumb_[1];

                $sumbImage = $sumbImage ? $sumbImage . ',' . $thumb1 : $thumb1;
            }

            $data['sumbImage'] = $sumbImage;
        }
    }
}
